/*
 * GeneralInfoView.cpp
 *
 *  Created on: 20/06/2014
 *      Author: javier
 */

#include "GeneralInfoView.h"
#include <iostream>
#include "BZPView.h"

#define TEXTURE_W 590.0f
#define TEXTURE_H 590.0f

GeneralInfoView::GeneralInfoView(BZPView* view, SDLWindow* window) {
	this->view = view;
	this->window = window;
	std::string resDir = properties.getProperty("res_dir");
	std::string textureName = resDir + "info.jpg";
	texture = window->loadTexture(textureName);
	geometry.x = 0;
	geometry.y = 0;
	geometry.w = properties.getPropertyAsInt("screen.width");
	geometry.h = properties.getPropertyAsInt("screen.height");
	state = (InfoStates)-1;
}

void GeneralInfoView::handleClick(int x, int y) {
	if (state == END_GAME){
		view->notifyEndGame();
	} else if (state == NEXT_MATCH){
		view->notifyNextMatch();
	}
	std::cout << "Aceptar" << std::endl;
}

void GeneralInfoView::render() {
	window->renderTexture(texture, &geometry);
	SDL_Color color = { 255, 255, 255 };
	window->renderTexture(window->renderText(info, color), 20, geometry.h/2);
}

GeneralInfoView::~GeneralInfoView() {
	// TODO Auto-generated destructor stub
}

const std::string& GeneralInfoView::getInfo() const {
	return info;
}

void GeneralInfoView::setInfo(const std::string info) {
	this->info = info;
}

InfoStates GeneralInfoView::getState() const {
	return state;
}

void GeneralInfoView::setState(InfoStates state) {
	this->state = state;
}
